local buqu = fk.CreateSkill {

  name = "joyex__buqu",

  tags = { Skill.Compulsory, },

}



buqu:addEffect(fk.DamageCaused, {
  name = "joyex__buqu",
  anim_type = "defensive",
  events = {fk.DamageCaused,fk.PreHpLost},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return ((target == player and event == fk.PreHpLost) or (data.to == player and event == fk.DamageCaused)) and player:hasSkill(buqu.name) and player:getMark("@joyex__chuang") < 4
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(player,"@joyex__chuang",1)
    return true
  end,
})
buqu:addEffect(fk.PreHpLost, {
  name = "joyex__buqu",
  anim_type = "defensive",
  events = {fk.DamageCaused,fk.PreHpLost},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return ((target == player and event == fk.PreHpLost) or (data.to == player and event == fk.DamageCaused)) and player:hasSkill(buqu.name) and player:getMark("@joyex__chuang") < 4
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(player,"@joyex__chuang",1)
    return true
  end,
})

buqu:addEffect("maxcards", {
  name = "#joyex__buqu_maxcards",
  frequency = Skill.Compulsory,
  correct_func = function(self, player)
    if player:hasSkill("joyex__buqu") then
      return player:getMark("@joyex__chuang")
    end
  end,
})

return buqu